<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" 
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
	xmlns:p="http://primefaces.org/ui"
	xmlns:h="http://java.sun.com/jsf/html"
	xmlns:f="http://java.sun.com/jsf/core"
	xmlns:ui="http://java.sun.com/jsf/facelets">
<ui:composition template="/pages/home.xhtml">
	<ui:define name="title">
		<h:outputText value="#{text.titReparticao}" />
	</ui:define>
	<ui:define name="content">

		<p:fieldset id="fieldSetPesquisaReparticao"
			legend="#{text.lgdPesquisaForm}" toggleable="true"
			binding="#{reparticaoController.fieldSetReparticao}">
			<h:inputHidden id="reparticaoId"
				value="#{reparticaoController.selectedReparticao.idReparticao}" />
			<h:panelGrid id="pnlFields" columns="4" cellpadding="4">
				<h:panelGroup>
					<h:outputLabel for="filterReparticaoCod"
						value="#{text.lblReparticaoCod}" />
					<p:spacer width="10px;" />
					<p:inputText id="filterReparticaoCod" size="15"
						value="#{searchHelper.filtersMap['reparticao']['codReparticao'].value}" />
				</h:panelGroup>
				<h:panelGroup>
					<h:outputLabel for="filterReparticaoDesc"
						value="#{text.lblReparticaoDesc}" />
					<p:spacer width="10px;" />
					<p:inputText id="filterReparticaoDesc" size="50"
						value="#{searchHelper.filtersMap['reparticao']['descReparticao'].value}" />
				</h:panelGroup>
				<h:panelGroup>
					<h:outputLabel for="filterReparticaoUF" value="#{text.lblUF}" />
					<p:spacer width="10px;" />
					<p:inputText id="filterReparticaoUF" size="15"
						value="#{searchHelper.filtersMap['reparticao']['uf.siglaUf'].value}" />
				</h:panelGroup>

			</h:panelGrid>
			<p:outputPanel style="padding:10px;">
				<p:commandButton id="btnNew" value="#{text.btnNew}"
					action="#{reparticaoController.newReparticao}" icon="ui-icon-document"
					immediate="true" async="true" ajax="false"
					onclick="grdReparticao.unselectAllRows();clearRadioDataTable();" />
				<p:commandButton id="btnSearch" value="#{text.btnSearch}"
					icon="ui-icon-search" update=":frmContent:grdReparticao" />
				<p:commandButton id="btnReset" value="#{text.btnReset}"
					icon="ui-icon-refresh" actionListener="#{searchHelper.reset}"
					update=":frmContent:grdReparticao, frmContent:fieldSetPesquisaReparticao" />
			</p:outputPanel>
		</p:fieldset>

		<p:spacer height="25" />

		<p:dataTable id="grdReparticao" var="reparticao"
			value="#{reparticaoController.reparticaoDataModel}"
			widgetVar="grdReparticao" emptyMessage="#{text.grdEmpty}"
			selection="#{reparticaoController.selectedReparticao}"
			selectionMode="single"
			paginator="true" rows="10" rowsPerPageTemplate="10,25,50"
			rowIndexVar="index"
			paginatorTemplate=" {FirstPageLink} {PreviousPageLink} {PageLinks} {NextPageLink} {LastPageLink} {RowsPerPageDropdown}"
			sortBy="#{reparticao.descReparticao}">

			<p:ajax event="rowSelect"
				update=":frmContent:fieldSetPesquisaReparticao" global="false"
				listener="#{reparticaoController.selectReparticao}" />

			<p:column id="colReparticaoEdit" headerText="#{text.btnEdit}" styleClass="cell-button">
				<p:commandButton id="btnEdit" onclick="grdReparticao.selectRow(#{index},'');loaderDialog.show();"
				oncomplete="redirect('/pages/reparticao/form.xhtml?selectedMenu=0');"
			    icon="ui-icon-pencil" immediate="true" global="false"/> 
			</p:column>
			
			<p:column id="colReparticaoCod" headerText="#{text.lblReparticaoCod}"
				sortBy="#{reparticao.codReparticao}" style="width:100px;">
				<h:outputText value="#{reparticao.codReparticao}"
					styleClass="cell-align-right" />
			</p:column>
			
			<p:column id="colReparticaoName"
				headerText="#{text.lblReparticaoDesc}"
				sortBy="#{reparticao.descReparticao}">
				<h:outputText value="#{reparticao.descReparticao}" />
			</p:column>
			
			<p:column id="colReparticaoUF" headerText="#{text.lblUF}"
				sortBy="#{reparticao.uf.siglaUf}" style="width:100px;">
				<h:outputText value="#{reparticao.uf.siglaUf}"
					styleClass="cell-align-center" />
			</p:column>

		</p:dataTable>
		<script type="text/javascript">
			function handleComplete(xhr, status, args) {
				if (!args.validationFailed) {
					$(
							PrimeFaces
									.escapeClientId("frmContent:reparticaoMessages"))
							.remove();
				}
			}
		</script>



	</ui:define>
</ui:composition>
</html>